package com.xmkj.bearuser.member;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bigkoo.pickerview.OptionsPickerView;
import com.common.mvp.BaseMvpFragment;
import com.common.mvp.BasePresenter;
import com.xmkj.bearuser.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Create by leo
 * 创建日期：2018/6/13
 * 描述：
 */

public class MemberFragment extends BaseMvpFragment {
    @BindView(R.id.ll_search)
    LinearLayout llSearch;
    @BindView(R.id.tv_quary)
    TextView tvQuary;
    @BindView(R.id.iv_next)
    ImageView ivNext;
    @BindView(R.id.tv_condition)
    TextView tvCondition;
    @BindView(R.id.rl_choose)
    RelativeLayout rlChoose;
    @BindView(R.id.day)
    RadioButton day;
    @BindView(R.id.week)
    RadioButton week;
    @BindView(R.id.mouth)
    RadioButton mouth;
    @BindView(R.id.year)
    RadioButton year;
    @BindView(R.id.radio_group)
    RadioGroup radioGroup;
    @BindView(R.id.progress1)
    ProgressBar progress1;
    @BindView(R.id.tv_active)
    TextView tvActive;
    @BindView(R.id.progress2)
    ProgressBar progress2;
    @BindView(R.id.tv_new)
    TextView tvNew;
    @BindView(R.id.progress3)
    ProgressBar progress3;
    @BindView(R.id.tv_consume)
    TextView tvConsume;
    @BindView(R.id.iv_add_member_list)
    ImageView ivAddMemberList;
    Unbinder unbinder;
    private List<String> outDatas = new ArrayList<>();
    private List<String> inDatas = new ArrayList<>();
    private List<List<String>> inListDatas = new ArrayList<>();
    private OptionsPickerView siteTypePicker;
    @Override
    protected BasePresenter createPresenterInstance() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_member;
    }

    @Override
    protected void onViewCreated(View view) {

    }

    @Override
    protected void doLogicFunc() {
        attachClickListener(ivAddMemberList);
        attachClickListener(llSearch);
        attachClickListener(rlChoose);
        initTypeOptionsPicker();

    }

    private void initDatas() {
        for (int i = 0; i < 3; i++) {
            outDatas.add("店铺" + i);
            for (int j = 0; j < 4; j++) {
                if(j==3){
                    inListDatas.add(inDatas);
                    inDatas = null;
                    inDatas = new ArrayList<>();
                }
                inDatas.add("商品"+j);
            }
        }
    }

    @Override
    protected void onViewClicked(View view) {
        if (view.getId() == ivAddMemberList.getId()) {

        } else if (view.getId() == llSearch.getId()) {
            gotoActivity(SearchAndMemberListActivity.class);
        }else if(view.getId()==rlChoose.getId()){
            if (siteTypePicker != null) {
                siteTypePicker.show();
            }
        }
    }
    private void initTypeOptionsPicker() {

        initDatas();

        siteTypePicker = new OptionsPickerView.Builder(context, new OptionsPickerView.OnOptionsSelectListener() {

            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {



            }
        }).setSubmitText(getString(R.string.insure)).
                setCancelText(getString(R.string.cacal)).
                build();
        siteTypePicker.setPicker(outDatas,inListDatas);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @Override
    public void bindKnife() {
        unbinder = ButterKnife.bind(this, view);
    }
}
